/*
 * <p>Title: 网址管理DAOImpl</p>
 * <p>Description: </p>
 * <p>尝试梦想项目组 2009. All rights reserved.</p>
 * @author 豪情
 * @version 1.0
 */
package com.navigation.dao.hibernate;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.navigation.dao.SiteDao;
import com.navigation.model.Site;

public class SiteDaoImpl extends HibernateDaoSupport implements SiteDao {

	/* (non-Javadoc)
	 * @see com.navigation.dao.SiteDao#findSiteByName()
	 */
	public Site findSiteById(Integer id) {
		List list = getHibernateTemplate().find("from Site where id=?", id);
		if (null != list && list.size() > 0) {
			return (Site)list.get(0);
		}
		return null;
	}

	/* (non-Javadoc)
	 * @see com.navigation.dao.SiteManageDao#delete(int)
	 */
	public void delete(int id) {
		getHibernateTemplate().delete(getHibernateTemplate().get(Site.class, id));
	}

	/* (non-Javadoc)
	 * @see com.navigation.dao.SiteManageDao#findAllSite()
	 */
	public List findAllSite() {
		return getHibernateTemplate().find("from Site");
	}

	/* (non-Javadoc)
	 * @see com.navigation.dao.SiteManageDao#get(int)
	 */
	public Site get(int id) {
		return (Site)getHibernateTemplate().get(Site.class, id);
	}

	/* (non-Javadoc)
	 * @see com.navigation.dao.SiteManageDao#save(com.navigation.model.SiteManage)
	 */
	public void save(Site site) {
		getHibernateTemplate().save(site);
	}

	/* (non-Javadoc)
	 * @see com.navigation.dao.SiteManageDao#update(com.navigation.model.SiteManage)
	 */
	public void update(Site site) {
		getHibernateTemplate().saveOrUpdate(site);
	}

}
